package com.ruoyi.system.service.impl;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Service;

@Service
public class TaskListener implements MessageListener {


    @Override
    public void onMessage(Message message, byte[] pattern) {
        JSONObject jsonObject = JSON.parseObject(new String(message.getBody()));
        Object key = jsonObject.get("key");
        String type = jsonObject.getString("type");
        switch (type){
            case "add":
                System.out.println(key);
                //针对消息key的处理
                break;
            case "del":
                System.out.println(key);
                //针对消息key的处理
                break;
            default:
                System.out.println(key);
                //针对消息key的处理
                return;
        }
    }
}
